﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DemoQLSV
{
    public partial class Main : Form
    {
        static bool is_KhoaHoc_Active = false;
        static bool is_SinhVien_Active = false;
        static bool is_DiemSo_Active = false;
        static bool is_LuuTru_Active = false;
        static bool is_HeThong_Active = false;
        static bool is_LogIn_Active = false;        
        public Main()
        {
            InitializeComponent();
            Main_Init_UserControl();// LIEU
            Main_Init_Header_button_list();// LIEU           
            // Active default
            Main_Active_Default();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (!GUI_QLSV.CGUI_Global.is_LogIn_success)
                return;
            Inactive_AllButton();
            Main_Init_Header_button_list();
            Hide_All_UserControl();
            Main_khoaHoc.Show();            
            is_KhoaHoc_Active = true;
            Reset_All_Button_Color();
            button_KhoaHoc.ForeColor = Color.Yellow;
            
        }

        private void Main_Load(object sender, EventArgs e)
        {           
        }

        //LIEU---------------------------------hide tat ca o trang thai ban dau
        private void Main_Active_Default()
        {
            is_LogIn_Active = true;
            Main_LogIn.Show();
            button_LogIn.ForeColor = Color.Yellow;
            button_LogIn.ImageKey = "DangNhap_Active.png";
        }
        private void Main_Init_UserControl()
        {
            this.Main_khoaHoc.Hide();
            this.Main_SinhVien.Hide();
            this.Main_LogIn.Hide();
        }
        private void Hide_All_UserControl()
        {
            this.Main_khoaHoc.Hide();
            this.Main_SinhVien.Hide();
            this.Main_DiemSo.Hide();
            this.Main_LogIn.Hide();
        }
        // init for header button list
        public void Main_Init_Header_button_list()
        {
            button_KhoaHoc.ImageKey = "KhoaHoc.png";
            button_SinhVien.ImageKey = "SinhVien.png";
            button_DiemSo.ImageKey = "DiemSo.png";
            button_LuuTru.ImageKey = "csdl.png";
            button_HeThong.ImageKey = "HeThong.png";
            if (!GUI_QLSV.CGUI_Global.is_LogIn_success)
            {
                button_LogIn.ImageKey = "DangNhap_Active.png";
                button_LogIn.Text = "Log In";                
                
            }
            else
            {
                if (is_LogIn_Active)
                    button_LogIn.ImageKey = "DangXuat_Active.png";
                else
                    button_LogIn.ImageKey = "DangXuat.png";
                button_LogIn.Text = "Log Out";
                
            }
        }

        //InActive All Button
        private void Inactive_AllButton()
        {
            is_KhoaHoc_Active = is_SinhVien_Active = is_DiemSo_Active = is_LuuTru_Active = is_HeThong_Active = is_LogIn_Active = false;
        }

        private void Reset_All_Button_Color()
        {
            button_KhoaHoc.ForeColor = Color.Blue;
            button_SinhVien.ForeColor = Color.Blue;
            button_DiemSo.ForeColor = Color.Blue;
            button_LuuTru.ForeColor = Color.Blue;
            button_HeThong.ForeColor = Color.Blue;
            button_LogIn.ForeColor = Color.Blue;
        }
        //END

        private void button_SinhVien_Click(object sender, EventArgs e)
        {
            if (!GUI_QLSV.CGUI_Global.is_LogIn_success)
                return;
            Hide_All_UserControl();
            this.Main_SinhVien.Show();
            Inactive_AllButton();
            Main_Init_Header_button_list();            
            is_SinhVien_Active = true;
            Reset_All_Button_Color();
            button_SinhVien.ForeColor = Color.Yellow;
        }

        private void button_DiemSo_Click(object sender, EventArgs e)
        {
            if (!GUI_QLSV.CGUI_Global.is_LogIn_success)
                return;
            Hide_All_UserControl();
            
            this.Main_DiemSo.Show();
            Inactive_AllButton();
            Main_Init_Header_button_list();            
            is_DiemSo_Active = true;
            Reset_All_Button_Color();
            button_DiemSo.ForeColor = Color.Yellow;
        }

        private void button_KhoaHoc_MouseMove(object sender, MouseEventArgs e)
        {            
            button_KhoaHoc.ImageKey = "KhoaHoc_Active.png";
        }

        private void button_KhoaHoc_MouseLeave(object sender, EventArgs e)
        {
            if (!is_KhoaHoc_Active)
            {
                button_KhoaHoc.ImageKey = "KhoaHoc.png";
                button_KhoaHoc.ForeColor = Color.Blue;
            }
            else
            {
                button_KhoaHoc.ImageKey = "KhoaHoc_Active.png";
                button_KhoaHoc.ForeColor = Color.Yellow;
            }           
        }

        private void button_SinhVien_MouseLeave(object sender, EventArgs e)
        {            
            if (!is_SinhVien_Active)
            {
                button_SinhVien.ImageKey = "SinhVien.png";
                button_SinhVien.ForeColor = Color.Blue;
            }
            else
            {
                button_SinhVien.ImageKey = "SinhVien_Active.png";
                button_SinhVien.ForeColor = Color.Yellow;
            }
        }

        private void button_SinhVien_MouseMove(object sender, MouseEventArgs e)
        {
            button_SinhVien.ImageKey = "SinhVien_Active.png";
        }

        private void button_DiemSo_MouseMove(object sender, MouseEventArgs e)
        {
            button_DiemSo.ImageKey = "DiemSo_Active.png";
        }

        private void button_DiemSo_MouseLeave(object sender, EventArgs e)
        {
            if (!is_DiemSo_Active)
            {
                button_DiemSo.ImageKey = "DiemSo.png";
                button_DiemSo.ForeColor = Color.Blue;
            }
            else
            {
                button_DiemSo.ImageKey = "DiemSo_Active.png";
                button_DiemSo.ForeColor = Color.Yellow;
            }

        }

        private void button_LuuTru_MouseLeave(object sender, EventArgs e)
        {
            if (!is_LuuTru_Active)
            {
                button_LuuTru.ImageKey = "CSDL.png";
                button_LuuTru.ForeColor = Color.Blue;
            }
            else
            {
                button_LuuTru.ImageKey = "CSDL_Active.png";
                button_LuuTru.ForeColor = Color.Yellow;
            }
        }

        private void button_LuuTru_MouseMove(object sender, MouseEventArgs e)
        {
            button_LuuTru.ImageKey = "CSDL_Active.png";
        }

        private void button_HeThong_MouseLeave(object sender, EventArgs e)
        {           
            if (!is_HeThong_Active)
            {
                button_HeThong.ImageKey = "HeThong.png";
                button_HeThong.ForeColor = Color.Blue;
            }
            else
            {
                button_HeThong.ImageKey = "HeThong_Active.png";
                button_HeThong.ForeColor = Color.Yellow;
            }
        }

        private void button_HeThong_MouseMove(object sender, MouseEventArgs e)
        {
            button_HeThong.ImageKey = "HeThong_Active.png";
        }

        private void button_LogIn_MouseMove(object sender, MouseEventArgs e)
        {                         
            if (!GUI_QLSV.CGUI_Global.is_LogIn_success)
            {
                button_LogIn.ImageKey = "DangNhap_Active.png";
                button_LogIn.Text = "Log In";
            }
            else
            {
                button_LogIn.ImageKey = "DangXuat_Active.png";
                button_LogIn.Text = "Log Out";
            }
        }

        private void button_LogIn_MouseLeave(object sender, EventArgs e)
        {
           
            if (!GUI_QLSV.CGUI_Global.is_LogIn_success)
            {
                if (!is_LogIn_Active)
                {
                    button_LogIn.ImageKey = "DangNhap.png";
                    button_LogIn.ForeColor = Color.Blue;
                }
                else
                {
                    button_LogIn.ImageKey = "DangNhap_Active.png";
                    button_LogIn.ForeColor = Color.Yellow;
                }
                button_LogIn.Text = "Log In";
            }
            else
            {
                if (!is_LogIn_Active)
                {
                    button_LogIn.ImageKey = "DangXuat.png";
                    button_LogIn.ForeColor = Color.Blue;
                }
                else
                {
                    button_LogIn.ImageKey = "DangXuat_Active.png";
                    button_LogIn.ForeColor = Color.Yellow;
                }                
                button_LogIn.Text = "Log Out";
            }
                
        }

        private void button_LuuTru_Click(object sender, EventArgs e)
        {
            if (!GUI_QLSV.CGUI_Global.is_LogIn_success)
                return;
            Inactive_AllButton();
            Main_Init_Header_button_list();            
            is_LuuTru_Active = true;
            Reset_All_Button_Color();
            button_LuuTru.ForeColor = Color.Yellow;
        }

        private void button_HeThong_Click(object sender, EventArgs e)
        {
            if (!GUI_QLSV.CGUI_Global.is_LogIn_success)
                return;
            Inactive_AllButton();
            Main_Init_Header_button_list();            
            is_HeThong_Active = true;
            Reset_All_Button_Color();
            button_HeThong.ForeColor = Color.Yellow;
        }

        private void button_LogIn_Click(object sender, EventArgs e)
        {
            
            if (!GUI_QLSV.CGUI_Global.is_LogIn_success)
                return;
            Inactive_AllButton();
            Main_Init_Header_button_list();            
            Hide_All_UserControl();
            Main_LogIn.Show();
            is_LogIn_Active = true;
            Reset_All_Button_Color();
            button_LogIn.ForeColor = Color.Yellow;
        }
        private void Main_LogIn_Click(object sender, System.EventArgs e)
        {            
            
        }

        private void Main_LogIn_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            Main_Init_Header_button_list();
        }
        void Main_LogIn_Paint(object sender, System.Windows.Forms.MouseEventArgs e)
        {
           // MessageBox.Show("");
        }
        void Main_LogIn_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            Main_Init_Header_button_list();
        }
    }
}
